﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YasharEl.Infrastructure.PersistenceModel.Dao
{
    public interface IBasePersistence<ModelType, PrimaryKeyType>
    {
        #region Create Methods

        ModelType Create(PrimaryKeyType primaryKey);

        #endregion

        #region Remove Methods

        ModelType Remove(PrimaryKeyType primaryKey);
        ModelType Remove(ModelType model);

        #endregion

        #region Update Methods

        /// <summary>
        ///     Add, update, or merge, the entity. This method also calls the model
        ///     listeners to trigger the proper events associated with adding, deleting,
        ///     or updating an entity.
        /// </summary>
        /// <param name="model">The model entity to add, update, or merge</param>
        /// <param name="merge">
        ///     Boolean value for whether to merge the entity.
        ///     The default value is false.Setting merge to true is more
        ///     expensive and should only be true when entity is transient.
        /// </param>
        /// <returns>Added,updated or merged entity.</returns>
        ModelType Update(ModelType model, bool merge);

        #endregion

        #region FindByPrimaryKey Methods

        ModelType FindByPrimaryKey(PrimaryKeyType primaryKey);

        #endregion

        #region FetchByPrimaryKey Methods

        ModelType FetchByPrimaryKey(PrimaryKeyType primaryKey);

        #endregion

        #region FindAll Methods

        IList<ModelType> FindAll();
        IList<ModelType> FindAll(int start, int end);
        IList<ModelType> FindAll(int start, int end, OrderByComparator comparator);

        #endregion

        #region RemoveAll Methods

        void RemoveAll();

        #endregion

        #region CountAll Methods

        void CountAll();

        #endregion
    }
}
